﻿Public Class FrmBBodega
    Public Property CodigoProducto As String
    Private rProductoBodega As GBDZafiro.ProductoBodega
    Public ReadOnly Property oProductoBodega As GBDZafiro.ProductoBodega
        Get
            Return rProductoBodega
        End Get
    End Property
    Private Sub FrmBBodega_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If Not String.IsNullOrEmpty(CodigoProducto) Then
            Dim dt As DataTable
            dt = GBDZafiro.ProductoBodega.ConsxCodProd(CodigoProducto)
            gvBodega.DataSource = dt
            gvBodega.Refresh()
            If dt.Rows.Count = 0 Then
                lbNoDatos.Visible = True
            Else
                lbNoDatos.Visible = False
            End If
        End If
    End Sub
    Private Sub RetornarBodega()
        rProductoBodega = New GBDZafiro.ProductoBodega
        rProductoBodega.codBodega = gvBodega.Item("COD_BODEGA", gvBodega.CurrentRow.Index).Value
        rProductoBodega.existencia = gvBodega.Item("EXISTENCIA", gvBodega.CurrentRow.Index).Value
        DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub gvBodega_CellDoubleClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gvBodega.CellDoubleClick
        RetornarBodega()
    End Sub

    Private Sub gvBodega_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles gvBodega.KeyDown
        If e.KeyCode = Keys.Enter Then
            RetornarBodega()
        End If
    End Sub
End Class